package com.borqs.music.tasks;

import com.borqs.music.executor.Task;
import com.borqs.music.executor.TaskListener;
import com.borqs.music.http.HttpRequest;
import com.borqs.music.http.HttpResponse;
import com.borqs.music.http.RequestMethod;
import com.borqs.music.model.SongInfo;
import com.borqs.music.util.MusicConf;

import java.util.HashMap;
import java.util.Map;

public class DeleteSongTask extends Task {

    private SongInfo song;
    private String ticket;

    public DeleteSongTask(TaskListener listener, SongInfo song, String ticket) {
        super(listener);
        this.song = song;
        this.ticket = ticket;
    }

    @Override
    public Object handleResponse(HttpResponse resp) throws Exception {
        checkResponse(resp);
        return song;
    }

    @Override
    public HttpRequest prepareRequest() {
        // normal parameters
        Map<String, String> params = new HashMap<String, String>(5);
        params.put("songid", String.valueOf(song.id));
        
        String url = MusicConf.getUrl(MusicConf.ReqType.MUSIC_DELETE_SONG);
        HttpRequest req = new HttpRequest(RequestMethod.GET, url, ticket, params);

        return req;
    }

}
